const express = require('express');
const app = express();

app.listen(8021, () => {
    // 打印一下接口用例地址
    console.log('http://localhost:8021')
})

const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({extended: false}))
app.use(bodyParser.json());

//设置跨域访问
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By", ' 3.2.1')
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});


// 关于test的接口，需要的内容
// 1.创建文件'./api/test/test.js',
// 2.let test='',
// 3.const test,
// 4.use test
let test_url = '/m'
const login_file = require('./m/login')
app.use(test_url,login_file)
const pages_file = require('./m/pages')
app.use(test_url,pages_file)
const upload_file = require('./m/upload')
app.use(test_url,upload_file)
